﻿package mortal.game.view.platform.platformTencent
{
    import com.mui.containers.globalVariable.*;
    import com.mui.controls.*;
    import fl.data.*;
    import flash.events.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.view.common.*;
    import mortal.game.view.nationalDayAct.*;
    import mortal.game.view.platform.*;
    import mortal.mvc.core.*;

    public class PlatformQQNewHandPanel extends PlatformTencentBasePanel
    {
        private var _newHandGift:GTileList;
        private var _newHandGiftBtn:GLoadingButton;

        public function PlatformQQNewHandPanel()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._newHandGift = UIFactory.tileList(6 + 145, 30 + 222 - 54 + 5, 500, 80, this);
            this._newHandGift.columnWidth = 43 + 40;
            this._newHandGift.rowHeight = 40 + 40;
            this._newHandGift.setStyle("cellRenderer", nationalDayActGiftCellRender);
            this._newHandGift.direction = GBoxDirection.HORIZONTAL;
            return;
        }// end function

        override protected function createYellow() : void
        {
            super.createYellow();
            _bg.imgUrl = ImagesConst.QQYeallowVipNewBg2;
            this._newHandGiftBtn = UIFactory.gLoadingButton(ResFileConst.QQYellowGetBtn, 100 + 141, 100 + 158 + 43, 64, 29, this);
            this._newHandGiftBtn.configEventListener(MouseEvent.CLICK, this.onClickHandle);
            return;
        }// end function

        override protected function createBlue() : void
        {
            super.createBlue();
            _bg.imgUrl = ImagesConst.QQBlueVipNew2;
            this._newHandGiftBtn = UIFactory.gLoadingButton(ResFileConst.QQBlueGetBtn, 100 + 141, 100 + 158 + 43, 64, 31, this);
            this._newHandGiftBtn.configEventListener(MouseEvent.CLICK, this.onClickHandle);
            return;
        }// end function

        private function onClickHandle(event:MouseEvent) : void
        {
            if (event.target == this._newHandGiftBtn)
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PlatformRequestQQYellowGift, PlatformGiftConfig.instance.newHandGift.id));
            }
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            if (this._newHandGift)
            {
                this._newHandGift.dispose(param1);
                this._newHandGift = null;
            }
            if (this._newHandGiftBtn)
            {
                this._newHandGiftBtn.dispose(param1);
                this._newHandGiftBtn = null;
            }
            super.disposeImpl(param1);
            return;
        }// end function

        override public function refresh() : void
        {
            var _loc_1:int = 0;
            this._newHandGift.dataProvider = this.getGiftListDataProviderByCode(PlatformGiftConfig.instance.newHandGift.reward);
            this._newHandGift.x = 6 + 145 + 73 - 40 - 0.5 * (this._newHandGift.dataProvider.length * 43);
            this._newHandGift.drawNow();
            if (PlatformTencentUtil.hasNewHandGiftReward())
            {
                if (this._newHandGiftBtn)
                {
                    setBtnCanGetStyle(this._newHandGiftBtn);
                }
            }
            else if (this._newHandGiftBtn)
            {
                setBtnCanNotGetStyle(this._newHandGiftBtn);
            }
            return;
        }// end function

        private function getGiftListDataProviderByCode(param1:int) : DataProvider
        {
            var _loc_5:Array = null;
            var _loc_6:ItemData = null;
            var _loc_9:nationalDayActGiftDataGroup = null;
            var _loc_2:* = new DataProvider();
            var _loc_3:* = new ItemData(param1).itemInfo as ItemGiftBagInfo;
            var _loc_4:* = _loc_3.itemList1.split("&");
            var _loc_7:* = _loc_4.length;
            var _loc_8:int = 0;
            while (_loc_8 < _loc_4.length)
            {
                
                _loc_5 = _loc_4[_loc_8].split("#");
                _loc_6 = new ItemData(int(_loc_5[1]));
                _loc_9 = new nationalDayActGiftDataGroup();
                _loc_9.itemCode = int(_loc_5[1]);
                _loc_9.itemData = _loc_6;
                _loc_9.itemAmount = _loc_5[2];
                _loc_9.isBind = true;
                _loc_2.addItem(_loc_9);
                _loc_8++;
            }
            return _loc_2;
        }// end function

    }
}
